home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / OS / FWGraphx / Include / FWGC.h < prev    next >
Encoding:
Text File  |  1994-04-21  |  4.0 KB  |  152 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWMGC.h
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Creation Date:        3/28/94
  7. //
  8. //    Copyright:    © 1993, 1994 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef FWGC_H
  13. #define FWGC_H
  14.  
  15. #ifndef FWGRDEF_H
  16. #include "FWGrDef.h"
  17. #endif
  18.  
  19. #ifndef FWPOINT_H
  20. #include "FWPoint.h"
  21. #endif
  22.  
  23. #ifndef FWRECT_H
  24. #include "FWRect.h"
  25. #endif
  26.  
  27. #ifndef FWINK_H
  28. #include "FWInk.h"
  29. #endif
  30.  
  31. #ifndef FWSTYLE_H
  32. #include "FWStyle.h"
  33. #endif
  34.  
  35. #ifndef FWSHAPE_H
  36. #include "FWShape.h"
  37. #endif
  38.  
  39. // ----- Macintosh Includes -----
  40.  
  41. #if defined(FW_BUILD_MAC) && !defined(__QUICKDRAW__)
  42. #include <QuickDraw.h>
  43. #endif
  44.  
  45. //========================================================================================
  46. //    •• Defines
  47. //========================================================================================
  48.  
  49. //========================================================================================
  50. //    •• Forward Declarations
  51. //========================================================================================
  52.  
  53. class XMPFacet;
  54. class XMPShape;
  55. class XMPWindow;
  56. class XMPCanvas;
  57.  
  58. //========================================================================================
  59. //    •• class FW_CGraphicContext
  60. //========================================================================================
  61.  
  62. class FW_CGraphicContext
  63. {
  64. //----------------------------------------------------------------------------------------
  65. //    • Constructors/Destructors
  66. //
  67. public:
  68.     FW_CGraphicContext(XMPFacet *facet, XMPShape* clipShape = NULL);
  69.     FW_CGraphicContext(XMPWindow* xmpWindow);
  70.     
  71.     virtual         ~FW_CGraphicContext();
  72.     
  73. //----------------------------------------------------------------------------------------
  74. //    • New API
  75. //
  76. public:
  77.     XMPCanvas*            GetCanvas() const;
  78.  
  79.     // ----- Conversion -----
  80.     FW_SPlatformPoint    AsPlatformPoint(const FW_CPoint& point);
  81.     FW_SPlatformRect    AsPlatformRect(const FW_CRect& rect);
  82.     FW_PlatformRegion    AsPlatformRegion(XMPShape* shape);
  83.     
  84.     // ----- ClipShape -----
  85.     void                GetClipShape(XMPShape* clipShape);
  86.     void                SetClipShape(XMPShape* clipShape);
  87.                             // a copy of clipShape is used
  88.     
  89.     void                SyncGraphicContext(XMPShape* clipShape);
  90.                             // a copy of clipShape is used
  91.     
  92.     // ----- Getters -----
  93.     XMPFacet*            GetXMPFacet() const
  94.                             {return fXMPFacet;}
  95.  
  96. private:
  97.     void                InvalidPreviousGCCache();
  98.  
  99. //----------------------------------------------------------------------------------------
  100. //    • Public but for internal use only
  101. //
  102. public:
  103.     void                SelectInkAndStyle(FW_CInk ink, FW_CStyle style, 
  104.                                             FW_ShapeCategory shapeType, FW_ShapeFills shapeFill);
  105.     
  106. //----------------------------------------------------------------------------------------
  107. //    • Data Members
  108. //
  109. private:
  110.     FW_CGraphicContext    *fPreviousGraphicContext;
  111.     
  112.     FW_Boolean            fWindowFocus;        // true if focusing on a window instead of a facet
  113.     
  114.     FW_Boolean            fForceSelect;        // when true, always call SelectInGC for the ink and style
  115.     
  116.     XMPFacet*            fXMPFacet;
  117.     XMPCanvas*            fXMPCanvas;
  118.  
  119.     unsigned long            fInkSeed;    
  120.     unsigned long            fStyleSeed;
  121.  
  122.     FW_ShapeCategory    fShapeCategory;        // Category of the last shape (geometric or typographic)
  123.     FW_ShapeFills        fShapeFills;        // how the last shape was drawn (framed or filled)
  124.     
  125. #ifdef FW_BUILD_MAC
  126.     GrafPtr                fPreviousPort;
  127.     FW_SPlatformPoint    fCurOrigin;
  128.     FW_PlatformRegion    fOldClip;
  129. #endif
  130.  
  131. #ifdef FW_BUILD_WIN
  132.     FW_CWinPen            fCurrentPen;
  133.     FW_CWinBrush        fCurrentBrush;
  134.     
  135.     FW_CWinPen            fPreviousPen;
  136.     FW_CWinBrush        fPreviousBrush;
  137. #endif
  138. };
  139.  
  140. //========================================================================================
  141. //    •• Inlines
  142. //========================================================================================
  143.  
  144. //----------------------------------------------------------------------------------------
  145. //    • FW_CGraphicContext::GetCanvas
  146. //----------------------------------------------------------------------------------------
  147. inline XMPCanvas* FW_CGraphicContext::GetCanvas() const
  148. {
  149.     return fXMPCanvas;
  150. }
  151.  
  152. #endif